package com.qf.spring.ioc.configuration;


import com.qf.spring.ioc.entity.Address;
import com.qf.spring.ioc.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置文件类
 */
@Configuration
public class BeanAnnotationConfig {

    @Bean
    //默认单例模式
//    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    //获取对象实例新new出来
//    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public User user() {
        User user = new User();
        user.setUserName("jerry");
        user.setPassword("123456");
        user.setAddress(address());
        return user;
    }

    @Bean
    public Address address() {
        Address address = new Address();
        address.setAddress("天河金丰");
        return address;
    }
}
